#! /bin/sh
#
# Laptop mode tools module: virtual terminal blanking
#

# Set terminal blanking/powerdown timeouts
if [ x$CONTROL_TERMINAL = x1 ] ; then
	if [ $ON_AC -eq 1 ]; then
		if [ "$ACTIVATE" -eq 1 ]; then
			BLANK_MINUTES="$LM_AC_TERMINAL_BLANK_MINUTES"
			POWERDOWN_MINUTES="$LM_AC_TERMINAL_POWERDOWN_MINUTES"
		else
			BLANK_MINUTES="$NOLM_AC_TERMINAL_BLANK_MINUTES"
			POWERDOWN_MINUTES="$NOLM_AC_TERMINAL_POWERDOWN_MINUTES"
		fi
	else
		BLANK_MINUTES="$BATT_TERMINAL_BLANK_MINUTES"
		POWERDOWN_MINUTES="$BATT_TERMINAL_POWERDOWN_MINUTES"
	fi
	log "VERBOSE" "Set terminal blanking timeout to $BLANK_MINUTES min, powerdown timeout to $POWERDOWN_MINUTES min."
	for THISTERMINAL in $TERMINALS ; do
		if [ -e $THISTERMINAL ] ; then
			log "VERBOSE" "Terminal $THISTERMINAL found, adjusting."
			TERM=linux setterm -blank "$BLANK_MINUTES" -powerdown "$POWERDOWN_MINUTES" > $THISTERMINAL
		else
			log "VERBOSE" "Terminal $THISTERMINAL does not exist."
		fi
	done
else
	log "VERBOSE" "CONTROL_TERMINAL is disabled, skipping..."
fi

